{include file="public/header"}
<style>
    #des{
        position: relative;
        z-index: 0;
    }
    .layui-upload-img{
        width: 100px;
        height: 100px;
    }
</style>
<form class="layui-form" lay-filter="layuiadmin-form-useradmin" id="layuiadmin-form-useradmin" style="padding: 20px 20px 20px 0;">
<!--    <div class="layui-upload">-->
<!--        <button type="button" class="layui-btn" id="uploadImage">上传图片</button>-->
<!--        <div class="layui-upload-list">-->
<!--            <img class="layui-upload-img" id="previewImage">-->
<!--            <input type="hidden" name="image" id="image" value="">-->
<!--            <p id="uploadText"></p >-->
<!--        </div>-->
<!--    </div>-->

    {volist name='config_list' id='item'}
    <div class="layui-form-item">
        <label class="layui-form-label">{$item.key_format}</label>
        <div class="layui-upload">
            <button type="button" class="layui-btn uploadImage" lay-data="{data:{key:'{$item.key}'}}">选择图片</button>
            <div class="layui-upload-list">
                <img class="layui-upload-img {$item.key}" src="{$item.value}">
                <input type="hidden" name="{$item.key}" id="{$item.key}" value="">
<!--                <p id="uploadText"></p >-->
            </div>
        </div>
<!--        <div class="layui-input-block">-->
<!--            <input value="{$item['value']}" type="text" name="time" placeholder="请输入日期" autocomplete="off" class="layui-input">-->
<!--        </div>-->
    </div>
    {/volist}


    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="LAY-user-front-submit" id="LAY-user-front-submit" value="确认">
    </div>
</form>

<script src="__ADMIN__/layuiadmin/layui/layui.js"></script>
<script type="text/javascript">
    window.HOST_TYPE='2'
</script>
<script>
    layui.config({
        base: '__ADMIN__/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['form', 'upload', 'layer'], function(){
        var $ = layui.$
            ,form = layui.form
            ,upload = layui.upload
            ,layer = layui.layer;

        //执行实例
        var uploadInst = upload.render({
            elem: '.uploadImage', //绑定元素
            url: '/api/app/upload', //上传接口
            // data: {key: $(this).attr('data-type')},
            accept: 'images',
            done: function(res) {
                console.log(res);
                //上传完毕回调
                $('#' + res.data.key).val(res.data.val); //将图片路径保存到表单中
                $('.' + res.data.key).attr('src', res.data.src); //预览图片
                // $('#uploadText').html('上传成功');
                layer.msg(res.msg, {icon: 1});
            },
            error: function() {
                //请求异常回调
                layer.msg('上传失败', {icon: 2});
            }
        });
    })
</script>
{include file="public/footer"}